<?php
$this->breadcrumbs = array(
     '广告管理' =>$this->rewriteCreateUrl('admin', array('WebAdsmanage[sort]' => $_GET["WebAdsmanage"]["sort"], 'siteid' => $_GET[siteid])),
);
Yii::app()->clientScript->registerScript('search', "
$('form.search-form').submit(function(){
	$.fn.yiiGridView.update('web-adsmanage-grid', {
		data: $(this).serialize()
	});
	return false;
});
$('#delete-button').click(function(){
    var selects = $.fn.yiiGridView.getSelection('web-adsmanage-grid');
    if(selects==''){
        alert('请选中记录进行操作！');
    }else{
       if(window.confirm('您确定要删除吗？')){
            $.fn.yiiGridView.update('web-adsmanage-grid', {
		type:'POST',
		url:'" . $this->rewriteCreateUrl('delete') . "',
                                    data:{id:selects},
		success:function(data) {
                                   $.fn.yiiGridView.update('web-adsmanage-grid');
                              
                                   //afterDelete(th,true,data);
		},
		error:function() {
                    //afterDelete(th,false);
		}
            });
            return false;
       }
    }
});

$('#web-adsmanage-grid tbody > tr > td.td_important >a ').click(function(){
    var state = 0;
    var ref_type = $(this).attr('ref');
    $('a[ref='+ref_type+']').attr('class','set-important');
    if(this.className=='set-important'){
        this.className='important';
        state = 1;
    }else{
        this.className='set-important';
        state = 0;
    }
    $.ajax({
        url:this.href,
        data:{state:state}
    });
    return false;
});
");
?>


<div class="box corners shadow">
    <div class="box-header">
        <h2>广告管理列表</h2>
        <div class="box-header-ctrls">	
            <a href="javascript:void(null);" title="" class="close"><!-- --></a>
        </div>
    </div>

    <div class="box-content" id="contacts-1a">
        <div class="inbox-sf">
            <form class="search-form">
                <?php echo CHtml::textField('WebAdsmanage[title]', '', array('class' => 'input-1 tip', 'title' => '输入广告标题查询')); ?>
                <?php echo CHtml::dropDownList('WebAdsmanage[webset]', '', array('' => '') + Subsite::model()->getSiteSelect(), array('class' => 'tip', 'title' => '选择域名查询')); ?> 
                <?php echo CHtml::dropDownList('WebAdsmanage[state]', '', array('' => '') + WebAdsmanage::model()->state_array, array('class' => 'tip', 'title' => '选择状态查询')); ?> 
                <input type="submit" name="" value="查询" class="inbox-sf-search-btn" />
            </form>
            <a class="button red fr"  href="<?php echo Yii::app()->controller->rewriteCreateUrl('WebAdsmanageSort/admin') ?>">
                <span>返回广告位管理</span>
            </a>
            <a class="button black fr tip" id="delete-button" href="javascript:void(null);" title="选中数据进行删除！">
                <span>批量删除</span>
            </a>
            <a class="button black fr" href="<?php echo $this->rewriteCreateUrl('create', array('WebAdsmanage[sort]'=>$_GET["WebAdsmanage"]["sort"],'siteid' =>$_GET[siteid])) ?>">
                <span>添加广告</span>
            </a>
        </div> 

        <?php
        $this->widget('zii.widgets.grid.CGridView', array(
            'id' => 'web-adsmanage-grid',
            'dataProvider' => $model->search(),
            'cssFile' => '',
            'htmlOptions' => array('class' => ''),
            'template' => '{summary}{items}{pager}',
            'itemsCssClass' => 'tablebox',
            'pager' => array(//通过pager设置样式   默认为CLinkPager
                'prevPageLabel' => '<<',
                'firstPageLabel' => '首页', //first,last 在默认样式中为{display:none}及不显示，通过样式{display:inline}即可
                'nextPageLabel' => '>>',
                'lastPageLabel' => '末页',
                'header' => '',
                'htmlOptions' => array('class' => 'box-nav')
            ),
            'selectableRows' => 2,
            'columns' => array(
                array(
                    'class' => 'CCheckBoxColumn',
                    'header' => '全选',
                    'value' => '$data->id',
                    'id' => 'delete',
                    'htmlOptions' => array('style' => 'width:20px')
                ),
                'id',
                'title',
                'url',
                array(
                    'name' => 'webset',
                    'value' => 'Subsite::model()->selectdomain($data->webset)',
                ),
                array(
                    'name' => 'sort',
                    'value' => 'WebAdsmanageSort::model()->getNameById($data->sort, "ads_name")',
                ),
                array(
                    'name' => 'state',
                    'type' => 'raw',
                    'htmlOptions' => array(
                        'class' => 'td_important',
                    ),
                    //      'value' => $model->state == 1 ? '激活' : '未激活',
                    'value' => 'WebAdsmanage::model()->getCustomerState($data)',
                ),
                'addtime',
                /*
                  'state',
                  'addtime',
                  'sort_order',
                 */
                array(
                    'type' => 'raw',
                    'htmlOptions' => array('style' => 'width:150px'),
                   'value' => 'WebAdsmanage::model()->getColumnOptions($data)',
                ),
            ),
        ));
        ?>         
    </div><!-- END ".box-content" --> 
</div>
